package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection()) {
            Statement statement = connection.createStatement();
            String sql="select id,name,age,title from teacher where salary > 8000";
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()){
                int id=resultSet.getInt("id");
                String name=resultSet.getString("name");
                int age=resultSet.getInt("age");
                String title=resultSet.getString("title");
                System.out.println(id+","+age+","+name+","+title);
            }
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}
